using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using SCS.Common.Models;
namespace SCS.DAL.Mapping
{
    public class ClassInSchoolYearMap : EntityTypeConfiguration<ClassInSchoolYear>
    {
        public ClassInSchoolYearMap()
        {
            // Primary Key
            this.HasKey(t => t.classInSchoolYearID);

            // Properties
            this.Property(t => t.classInSchoolYearID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.className)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("ClassInSchoolYear");
            this.Property(t => t.classInSchoolYearID).HasColumnName("classInSchoolYearID");
            this.Property(t => t.schoolYearID).HasColumnName("schoolYearID");
            this.Property(t => t.classID).HasColumnName("classID");
            this.Property(t => t.className).HasColumnName("className");

            // Relationships
            this.HasRequired(t => t.Class)
                .WithMany(t => t.ClassInSchoolYears)
                .HasForeignKey(d => d.classID);
            this.HasRequired(t => t.SchoolYear)
                .WithMany(t => t.ClassInSchoolYears)
                .HasForeignKey(d => d.schoolYearID);

        }
    }
}
